import axios from "../config.js";

/**
 * 分页查询管理员
 * @returns {Promise<unknown>}
 */
export const findPage = data => {
  return axios({
    url: "/user/findPage",
    method: "get",
    params: data
  });
};

/**
 * 查询所有管理员
 * @returns {Promise<unknown>}
 */
export const findAll = data => {
  return axios({
    url: "/user/findAll",
    method: "get",
    params: data
  });
};

/**
 * 通过管理员姓名分页查询
 * @returns {Promise<unknown>}
 */
export const findPageByName = data => {
  return axios({
    url: "/user/findPageByName",
    method: "get",
    params: data
  });
};

/**
 * 添加管理员
 * @param data
 * @returns {Promise<unknown>}
 */
export const add = data => {
  return axios({
    url: "/user/add",
    method: "post",
    data
  });
};

/**
 * 更新管理员信息
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export const update = data => {
  return axios({
    url: "/user/update/" + data.id,
    method: "put",
    params: data
  });
};

/**
 * 删除管理员
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export const delUser = data => {
  return axios({
    url: "/user/delete/" + data,
    method: "delete"
  });
};
